package com.iweb.web.servlet;

import com.iweb.commons.utils.BeanUtil;
import com.iweb.commons.utils.ModelAndView;
import com.iweb.commons.utils.UrlUtil;
import com.iweb.web.controller.MerchantController;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author: jack
 * @date: 2022-08-05 0005
 * @ApiNOTE:
 */
@WebServlet(urlPatterns = "/merchant/*", loadOnStartup = 1)
public class MerchantServlet extends HttpServlet {
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    String action = UrlUtil.action(req, "/merchant/");

    if ("info".equals(action)) {
      info(req, resp);
    }
  }

  private void info(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    HttpSession session = req.getSession();

    MerchantController merchantController = BeanUtil.getBean(getServletContext(), "mer");

    ModelAndView mv = merchantController.merchantInfo(session);

    mv.render(req, resp, mv);


  }
}
